new Vue({
    template: `
      <div>
        <div v-if="isDefPlayVideoPage">
          <button gz_type @click="listHighAdaptationBut">视频页合集列表自适应高度</button>
          <button gz_type @click="listHighlyRestoredBut">视频页合集列表高度复原</button>
        </div>
        <div v-if="isCheckBackLaterPlayVideoPage">
          <button gz_type @click="listHighAdaptationCheckBackLaterBut">视频页合集列表自适应高度(稍后再看)</button>
          <button gz_type @click="listHighCheckBackLaterRestoredBut">视频页合集列表高度(稍后再看)</button>
        </div>
        <div>
          <button gz_type @click="openSearchDrawerGzBut">打开合集搜索栏</button>
        </div>
      </div>`,
    el: "#collection",
    data() {
        return {
            //当前是否默认播放页
            isDefPlayVideoPage: false,
            //当前是否稍后再看播放页
            isCheckBackLaterPlayVideoPage: false,
            //默认视频页列表最大高度
            defVideoListMaxHeight: null,
            //稍后再看视频页列表最大高度-body
            videoCheckBackLaterListBodyMaxHeight: null,
            //稍后再看视频页列表最大高度-内层list
            videoCheckBackLaterListMaxHeight: null,
        }
    },
    methods: {
        openSearchDrawerGzBut() {
            searchDrawerGz.show(true);
            drawerGz.show(false);
        },
        //合集列表高度自适应
        listHighAdaptationBut() {
            getDefVideoPlayPageListEl().then(el => {
                if (this.defVideoListMaxHeight === null) {
                    this.defVideoListMaxHeight = el.style.maxHeight;
                }
                el.style.maxHeight = "max-content";
                Tips.successBottomRight("已自适应高度！")
            })
        },
        //合集列表高度复原
        listHighlyRestoredBut() {
            if (this.defVideoListMaxHeight === null) {
                Tips.errorBottomRight("未自适应高度！无需调整.");
                return;
            }
            getDefVideoPlayPageListEl().then(el => {
                el.style.maxHeight = this.defVideoListMaxHeight;
            })
            Tips.successBottomRight("已复原视频页合集列表高度");
        },
        //合集列表高度自适应(稍后再看)
        listHighAdaptationCheckBackLaterBut() {
            getCheckBackLaterVideoListElements().then(({bodyList, listEl, defList}) => {
                if (this.videoCheckBackLaterListBodyMaxHeight === null) {
                    this.videoCheckBackLaterListBodyMaxHeight = bodyList.style.maxHeight;
                    this.videoCheckBackLaterListMaxHeight = listEl.style.maxHeight;
                }
                for (let el of defList) {
                    el.style.maxHeight = "max-content";
                }
            })
        },
        //合集列表高度复原(稍后再看)
        listHighCheckBackLaterRestoredBut() {
            if (this.videoCheckBackLaterListBodyMaxHeight === null) {
                Tips.errorBottomRight("未自适应高度！无需调整.");
                return;
            }
            getCheckBackLaterVideoListElements().then(({bodyList, listEl}) => {
                bodyList.style.maxHeight = this.videoCheckBackLaterListBodyMaxHeight;
                listEl.style.maxHeight = this.videoCheckBackLaterListMaxHeight;
            });
        }
    },
    created() {
        this.isDefPlayVideoPage = global_BiliBIli_video_page_settings_dataVue["isDefPlayVideoPage"];
        this.isCheckBackLaterPlayVideoPage = global_BiliBIli_video_page_settings_dataVue["isCheckBackLaterPlayVideoPage"];
    }
});
